package controller

import (
	"github.com/gin-gonic/gin"
	"github.com/gogf/gf/v2/frame/g"
	"net/http"
	"template/api"
	"template/pkg/code"
)

func TestController(c *gin.Context) {
	req := &api.TestReq{}
	if err := c.ShouldBindJSON(&req); err != nil {
		code.Fail(c, http.StatusBadRequest, code.ErrEncodingJSON, err.Error())
		return
	}
	// 数据校验
	if err := g.Validator().Data(req).Run(c); err != nil {
		code.Fail(c, http.StatusBadRequest, code.ErrValidation, err.Error())
		return
	}
	code.Success(c, nil)
}
